package zzuli.edu.cn.controller;

import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import zzuli.edu.cn.dao.pojo.Student;

/**
 * https://blog.csdn.net/dejunyang/article/details/89527330
 * 当 @ApiResponse 注解作用在方法类或接口上时，表示的是对此类或接口中所有方法的返回结果进行说明
 */
@RestController
@Api(value = "@ApiResponses 注解和 @ApiResponse 注解测试2", tags = "@ApiResponses 注解和 @ApiResponse 注解测试2")
@ApiResponses(value = {
        @ApiResponse(code = 200, response = Student.class, message = "调用成功"),
        @ApiResponse(code = 404, response = Student.class, message = "调用失败，失败原因：地址错误")
})
public class Swagger2Controller6 {

    @ApiOperation(value = "@ApiResponses 和 @ApiResponse 测试2", notes = "此方法用于@ApiResponses 和 @ApiResponse 测试2")
    @PostMapping("/apiResponse2")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "name", value = "姓名", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "age",  value = "年龄", required = true, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "sex",  value = "性别", required = true, paramType = "query", dataType = "String")
    })
    public Student createStudent2(String name, int age, String sex) {
        return new Student(name, age, sex);
    }

    @ApiOperation(value = "@ApiResponses 和 @ApiResponse 测试3", notes = "此方法用于@ApiResponses 和 @ApiResponse 测试3")
    @PostMapping("/apiResponse3")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "name", value = "姓名", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "age",  value = "年龄", required = true, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "sex",  value = "性别", required = true, paramType = "query", dataType = "String")
    })
    public Student createStudent3(String name, int age, String sex) {
        return new Student(name, age, sex);
    }

}
